﻿@using eCollabro.Client.Models.Content;
@using eCollabro.Client.Models.Core;
@using eCollabro.Web.Base;
@using eCollabro.Common;
@model DocumentLibraryModel
@{
    List<PermissionEnum> userPermissions = (List<PermissionEnum>)ViewBag.UserPermissions;
    bool canEdit = userPermissions.Contains(PermissionEnum.EditContent);
    bool canDelete = userPermissions.Contains(PermissionEnum.DeleteContent);
    bool canAdd = userPermissions.Contains(PermissionEnum.AddContent); 
    List<PageButton> pageButtons = new List<PageButton>();
    pageButtons.Add(new PageButton { Id = "btnRefresh", CssClass = "btn btn-warning", ButtonText = "Refresh", Icon = "refresh", Method = "loadDocuments()" });
    pageButtons.Add(new PageButton { Id = "btnDocumentLibraries", CssClass = "btn btn-success", ButtonText = "Document Libraries", Icon = "th-list", Method = "documentLibraries()" });
    if (canAdd)
    {
        pageButtons.Add(new PageButton { Id = "btnAdd", CssClass = "btn btn-success", ButtonText = "Add Document", Icon = "plus", Method = "openDocument(0," + Model.DocumentLibraryId + ")" });
    }
}
@Scripts.Render("~/bundles/documentlibrary") 
<div id="placeHolderDocuments"></div>
<div id="divDocuments" ng-controller="documentsController" ng-init="initialize(@Model.DocumentLibraryId,'@canAdd','@canEdit','@canDelete')">
    @Html.Partial("_PageHeader", new PageHeaderModel { ViewId = "Documents", PageTitle = "Documents - {{documentLibrary.DocumentLibraryName}}", PageButtons = pageButtons })
    <table style="width:100%" class="table table-striped table-bordered" id="tblDocuments" cellspacing="0">
        <thead>
            <tr>
                @if (canAdd || canEdit || canDelete) // Contributor
                {
                    <th>Id #</th>
                    <th style="width:400px">Title</th>
                    <th>Active</th>
                    <th>Approved</th>
                    <th>Action</th>
                }
                else
                {
                    <th>Title</th>
                }
            </tr>
        </thead>
    </table>
</div>
